<template>
	<view>
		<detailPage
			:pageUrl="pageUrl"
			:editFormOptions="editFormOptions"
			:editFormFields="editFormFields"
			:detailColumns="detailColumns"
			@masterDate="masterDate"
			:titel="titel"
		></detailPage>
	</view>
</template>
<script>
export default {
	data() {
		return {
			titel: '',
			pageUrl: 'q_operations_return',
			editFormFields: {
				Voucher_sub: '',
				Goods_num: '',
				Total_price: '',
				Tax_exclusive_total_price: '',
				Supplier: ''
			},
			editFormOptions: [
				{
					title: 'ID',
					required: true,
					field: 'Operations_return',
					hidden: true,
					readonly: true
				},
				{
					title: '单据编码',
					field: 'Voucher_sub',
					readonly: true
				},
				{
					title: '运维发货单',
					field: 'Fittings_delivery_sub',
					readonly: true
				},
				{
					title: '商品数量',
					field: 'Goods_num',
					readonly: true
				},
				{
					title: '退货机构',
					field: 'WHSE_no',
					readonly: true,
					data: [],
					key: '一级仓库'
				}
			],
			detailColumns: [
				{
					field: 'Operations_returnList',
					title: 'ID',
					hidden: true
				},
				{
					field: 'Goods_sub',
					title: '商品编码',
					readonly: true
				},
				{
					field: 'Goods_name',
					title: '商品名称',
					readonly: true
				},
				{
					field: 'Goods_size',
					title: '规格型号',
					readonly: true
				},
				{
					field: 'AvailableQuantity',
					title: '可用数量',
					type: 'string',
					readonly: true
				},
				{
					field: 'Goods_num',
					title: '退货数量',
					type: 'string',
					readonly: true
				},
				{
					field: 'Remark',
					title: '备注',
					type: 'string',
					readonly: true
				},
				{
					field: 'WHSE_name',
					title: '库位名称',
					readonly: true,
					data: [],
					key: '库位编码',
					type: 'select'
				}
			]
		};
	},
	onLoad() {
		this.detailColumns.forEach((obj) => {
			if (obj.type == 'select') {
				this.http.post('api/Sys_Dictionary/GetVueDictionary', [obj.key], true).then((result) => {
					if (result.length) {
						for (var index = 0; index < result.length; index++) {
							if (result[index].dicNo == obj.key) {
								obj.data = result[index].data;
							}
						}
					}
				});
			}
		});
	},
	methods: {
		masterDate(val) {
			Object.assign(this.editFormFields, val);
		}
	}
};
</script>
